package com.chatcompetition.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chatcompetition.domain.entity.CompetitionActivity;
import com.chatcompetition.mapper.CompetitionMapper;
import com.chatcompetition.service.LifeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LifeServiceImpl extends ServiceImpl<CompetitionMapper, CompetitionActivity> implements LifeService {
    @Autowired
    private CompetitionMapper competitionMapper;

    @Override
    public List<CompetitionActivity> listAll() {
        // 查询类别为 "竞赛" 的记录
        QueryWrapper<CompetitionActivity> wrapper = new QueryWrapper<>();
        wrapper.eq("category", "生活");
        return competitionMapper.selectList(wrapper);
    }


    @Override
    public boolean update(CompetitionActivity activity) {
        return updateById(activity);
    }

    @Override
    public boolean delete(Long id) {
        return removeById(id);
    }
}
